#include<iostream>
#include<vector>
#include<string>

using namespace std;

//回溯-剪枝01：全排列
class Solution1 {
public:
    vector<vector<int>> ret;
    vector<int> path;
    bool check[7]={};
    vector<vector<int>> permute(vector<int>& nums) 
    {
        dfs(nums);
        return ret;
    }

    void dfs(vector<int>& nums)
    {
        if(path.size()==nums.size())
        {
            ret.push_back(path);
            return;
        }

        for(int i=0;i<nums.size();i++)
        {
            if(!check[i])
            {
                path.push_back(nums[i]);
                check[i]=true;
                dfs(nums);
                path.pop_back();
                check[i]=false;
            }            
        }
    }
};


////回溯-剪枝02：子集
class Solution2 {
public:
    vector<vector<int>> ret;
    vector<int> path;
    //bool check[10]={};
    vector<vector<int>> subsets(vector<int>& nums) 
    {
        dfs(nums,0);
        return ret;
    }

    void dfs(vector<int>& nums,int i)
    {
        if(i==nums.size())
        {
            ret.push_back(path);
            return;
        }

        //ret.push_back(path);
        path.push_back(nums[i]);
        dfs(nums,i+1);//代表选了nums[i]
        path.pop_back();
        dfs(nums,i+1);//代表没选nums[i]
        
    }
};



int main()
{
    return 0;
}